class Solution
{
public:
    string kthLargestNumber(vector<string> &nums, int k)
    {
        priority_queue<string, vector<string>, NumStringComparator> numsHeap;
        NumStringComparator greater;
        int n = nums.size();
        for (int i = 0; i < n; ++i)
        {
            if (numsHeap.size() < k)
            {
                numsHeap.push(nums[i]);
            }
            else
            {
                if (greater(nums[i], numsHeap.top()))
                {
                    numsHeap.pop();
                    numsHeap.push(nums[i]);
                }
            }
        }
        return numsHeap.top();
    }

    class NumStringComparator
    {
    public:
        bool operator()(const string &s1, const string &s2)
        {
            if (s1.size() != s2.size())
            {
                return s1.size() > s2.size();
            }
            return s1 > s2;
        }
    };
};